<template>
  <div>
      <WelTop active='recipeTab'></WelTop>
      <div class="container">
        <div class="content">
            <div class="scrollBox">
                <div class="searchBarBox">
                    <div class="searchBar">
                        <div class="searchIcon"></div>
                        <div class="searchTxt">搜菜名 食材</div>
                    </div>
                </div>
                <div class="navBox">
                    <div class="nav">
                        <div class="navs" v-for="val in recipeArry" :key="val.id">
                            <div class="nImg">
                                <img :src="imgUrl+val.arry">
                            </div>
                            <div class="nTxt">{{val.text}}</div>
                        </div>
                    </div>
                </div>
                <div class="hotScollBox">
                    <div class="hotTitle">热门食谱</div>
                    <div class="list">
                        <div v-for="val in hotRecipe" :key="val.id">
                            <div class="topPic item" v-for="toppic in val.top" :key="toppic.id">
                                <div class="pic">
                                    <div class="img" :style="'background-image: url('+imgUrl+toppic.pic+')'"></div>
                                </div>
                                <div class="txt">
                                    <p>{{toppic.text}}</p>
                                    <div class="txtBottom">
                                        <div class="userInfo">
                                            <img :src="imgUrl+toppic.userInfo">
                                            <span class="username">{{toppic.userName}}</span>
                                        </div>
                                        <div class="readCount">10000+</div>
                                    </div>
                                </div>
                            </div>
                            <div class="leftPic item" v-for="leftpic in val.left" :key="leftpic.id">
                                <div class="pic">
                                    <img :src="imgUrl+leftpic.pic">
                                </div>
                                <div class="txt">
                                    <p>{{leftpic.text}}</p>
                                    <div class="txtBottom">
                                        <div class="userInfo">
                                            <img :src="imgUrl+leftpic.userInfo">
                                            <div class="username">{{leftpic.userName}}</div>
                                        </div>
                                        <div class="readCount">{{leftpic.readCount}}w</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
      </div>
      <AppFooter active='welfareTab'></AppFooter>
  </div>
</template>

<script>
import WelTop from '@/components/WelTop'
import $ from 'jquery'
export default {
    data(){
        return {
            recipeArry:[],
            hotRecipe:[]
        }
    },
    created(){
        this.getRecipeArry();
        this.getHotRecipe();
    },
    methods:{
        getRecipeArry(){
            this.axios.get('/recipearry').then((ret)=>{
                let {data,error}=ret.data;
                this.recipeArry=data;
            }).catch(()=>{})
        },
        getHotRecipe(){
            this.axios.get('/hotrecipe').then((ret)=>{
                let {data,error}=ret.data;
                this.hotRecipe=data;
            }).catch(()=>{})
        }
    },
    components:{
        WelTop
    }
}
</script>

<style scoped lang='scss'>
.container{
    background-color: #f8f8f8;
    .content{
        padding-top: 117px;
        .scrollBox{
            .searchBarBox{
                background-color: #fff;
                padding: 7px 23px 23px;
                .searchBar{
                    height: 79px;
                    width: 100%;
                    background-color: #f8f8f8;
                    font-size: 32px;
                    line-height: 79px;
                    border-radius: 39px;
                    box-sizing: border-box;
                    text-align: center;
                    color: #999;
                    position: relative;
                    .searchIcon{
                        width: 32px;
                        height: 32px;
                        position: absolute;
                        top: 50%;
                        left: 230px;
                        margin-top: -14px;
                        background: url(/static/recipe/index_icon_sea.png) no-repeat;
                        background-size: 30px auto;
                    }
                }
            }
            .navBox{
                margin: 23px;
                background-color: #fff;
                border-radius: 14px;
                .nav{
                    border-radius: 14px;
                    background-color: #fff;
                    padding: 30px 10px;
                    display: flex;
                    flex-wrap: wrap;
                    justify-content: space-between;
                    div.navs:nth-child(5n){
                        margin-right:0;
                    }
                    div.navs:nth-child(6),div.navs:nth-child(7),div.navs:nth-child(8),div.navs:nth-child(9),div.navs:nth-child(10){
                        margin-bottom:0;
                    }
                    .navs{
                        width: 103px;
                        margin-right: 27px;
                        margin-bottom: 34px;
                        .nImg{
                            width:103px;
                            height: 103px;
                            border-radius: 50px;
                            overflow: hidden;
                            img{
                                width: 100%;
                                height: 100%;
                            }
                        }
                        .nTxt{
                            text-align: center;
                            font-size: 28px;
                            margin: 18px 0 0 -4px;
                            width: 109.8%;
                        }
                    }
                }
            }
            .hotScollBox{
                .hotTitle{
                    margin: 70px 23px 35px;
                    color:#333;
                    font-weight: 700;
                    font-size: 42px;
                    line-height: 50px
                }
                .list{
                    padding: 0 23px;
                    .item{
                        background-color: #fff;
                        border-radius: 14px;
                        border:none;
                        margin: 23px 0;
                        .pic{
                            overflow: hidden;
                            .img{
                                background-color: #f4f4f4;
                                background-repeat: no-repeat;
                                background-position: 50%;
                                background-size:cover;
                            }
                        }
                        .txt{
                            padding: 23px;
                            p{
                                overflow: hidden;
                                text-overflow: ellipsis;
                                display:-webkit-box;
                                -webkit-line-clamp:2;
                                -webkit-box-orient:vertical;
                                font-size:37px;
                                font-weight: 700;
                                color:#333;
                                line-height: 46px;
                                max-height: 97px;
                            }
                            .txtBottom{
                                display: flex;
                                .userInfo{
                                    overflow: hidden;
                                    text-overflow: ellipsis;
                                    white-space: nowrap;
                                    display: flex;
                                    flex: 1 1;
                                    img{
                                        width: 46px;
                                        height: 46px;
                                        margin-right: 11px;
                                        border-radius: 46px;
                                    }
                                    .username{
                                        font-size: 28px;
                                        font-weight: 300;
                                        color: #666;
                                        display: block;
                                        height: 46px;
                                        line-height: 46px;
                                    }
                                }
                                .readCount{
                                    overflow: hidden;
                                    text-overflow: ellipsis;
                                    white-space: nowrap;
                                    max-width: 201px;
                                    font-size: 32px;
                                    color:#555;
                                    line-height: 46px;
                                    &::before{
                                        content: '';
                                        background: url(/static/recipe/eye.png) no-repeat;
                                        background-size: 100%;
                                        height: 30px;
                                        width: 30px;
                                        margin: 7px 7px 7px 23px;
                                        float: left;
                                    }
                                }
                            }
                        }
                    }
                    .topPic{
                        .pic{
                            width: 100%;
                            border-radius: 14px 14px 0 0;
                            border: none;
                            .img{
                                height: 314px;
                            }
                        }
                        .txt{
                            p{
                                margin-bottom: 35px;
                                margin-top: 0;
                            }
                        }
                    }
                    .leftPic{
                        height: 310px;
                        .pic{ 
                            height: 310px;
                            width: 310px;
                            border-radius: 14px 0 0 14px;
                            float: left;
                            img{
                                width: 310px;
                                height: 310px;
                                border-radius: 14px 0 0 14px;
                                float: left;
                            }
                        }
                        .txt{
                            height:262px ;
                            display: flex;
                            -webkit-box-orient:vertical;
                            -webkit-box-direction:normal;
                            flex-direction:column;
                            p{
                                margin: 0;
                            }
                            .txtBottom{
                                height: 85%;
                                align-items: flex-end;
                                flex: 1;
                                display: flex;
                                .username{
                                    overflow: hidden;
                                    text-overflow: ellipsis;
                                    white-space: nowrap;
                                    flex: 1;
                                }
                                .readCount{
                                    overflow: hidden;
                                    text-overflow: ellipsis;
                                    white-space: nowrap;
                                    flex: 1;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
</style>

